(function($) {     
  //插件主要内容     
  $.fn.lin_resizePic = function(options){     
      // 处理默认参数   
      var opts = $.extend({}, $.fn.lin_resizePic.defaults, options);  
      return this.each(function()
      {
		  var $this=$(this);
		  var $images=$this.find("img");
		  if($.browser.msie || $.browser.mozilla)
		  {
				$images.each(function(){	
						$.fn.lin_resizePic.effect[opts.effect](this,opts.maxWidth,opts.maxHeight);
				});
		  }else
			  { 
				$images.each(function(){
					 this.onload=function(){
						$.fn.lin_resizePic.effect[opts.effect](this,opts.maxWidth,opts.maxHeight);
					 }
				});
			  }	 	
	  });  
   };    
   $.fn.lin_resizePic.defaults = {
        maxWidth:200,
		maxHeight:300,
		effect:"basic"
    };
	$.fn.lin_resizePic.effect=
	{
		basic:function(drawImage,width,height){  
    		var fixwidth = width;   
   			var fixheight =height;  
    		w=drawImage.width;
			h=drawImage.height;
    		if(w>fixwidth){drawImage.width=fixwidth;drawImage.height=h/(w/fixwidth);}   
    		if(h>fixheight){drawImage.height=fixheight;drawImage.width=w/(h/fixheight);}         
    		drawImage.style.cursor= "pointer";   
    		drawImage.onclick = function(){window.open(this.src);}    
    		drawImage.title = "点击查看原始图片";			
		},
		//等比例缩放
		proportion:function(drawImage,w,h){
			var image=new Image();
			image.src=drawImage.src;
			if(image.width>0 && image.height>0)
			{
				if(image.width/image.height>= w/h)
				{
    				if(image.width>w)
					{
      					drawImage.width=w;
     					drawImage.height=(image.height*w)/image.width;
    				}else{
     					   drawImage.width=image.width;
      				       drawImage.height=image.height;
    					 }
				}else{
    				   if(image.height>h)
					   {
      					 drawImage.height=h;
      					 drawImage.width=(image.width*h)/image.height;
   					   }else{
      					      drawImage.width=image.width;
      					      drawImage.height=image.height;
   						    }
					 }
			}			
		}
    }
// 闭包结束     
})(jQuery); 